package com.gvfish.backingbean;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import org.springframework.context.ApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;

import com.gvfish.entity.Constant;
import com.gvfish.service.ConstantManager;

@ManagedBean
@RequestScoped
public class ConstantBean {
	ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
	ConstantManager constantManager= (ConstantManager)ctx.getBean("constantManager");
	private List<Constant> constants = constantManager.findAll();
	
	
	private DataModel<Constant> constantModel = new ListDataModel<Constant>();
	{
		constantModel.setWrappedData(constants);
	}
	
	public DataModel<Constant>  getAll(){
		return constantModel;
	}

	public void setConstants(List<Constant> constants) {
		this.constants = constants;
	}

	public List<Constant> getConstants() {
		return constants;
	}
}
